using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class MemberEmployeeMap : EntityTypeConfiguration<MemberEmployee>
	{
		public MemberEmployeeMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("MemberEmployees");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.MembershipId).HasColumnName("MembershipId");
			this.Property(t => t.EmployeeId).HasColumnName("EmployeeId");

			// Relationships
			this.HasOptional(t => t.Employee)
				.WithMany(t => t.MemberEmployees)
				.HasForeignKey(d => d.EmployeeId);
				
			this.HasOptional(t => t.SysMembership)
				.WithMany(t => t.MemberEmployees)
				.HasForeignKey(d => d.MembershipId);
				
		}
	}
}

